package firing;

import firing.Node;

public abstract class AbstractBinaryNode implements BinaryNode {

    private static final long serialVersionUID = -1889127926385821179L;
    protected Node left;
    protected Node right;
    
    public Node getLeftChild() {
	return left;
    }
    
    public Node getRightChild() {
	return right;
    }
    
    public void setLeftChild(Node left) {
	this.left = left;
    }

    public void setRightChild(Node right) {
	this.right = right;
    }

    public boolean isUnaryNode() {
	return false;
    }
    
    public String printNode(int depth) {
	StringBuilder sb = new StringBuilder();
	for(int i=0;i<depth;i++) {
	    sb.append("-  ");
	}
	sb.append(toString());
	sb.append('\n');
	if (left != null) {
	    sb.append(left.printNode(depth + 1));
	} else {
	    sb.append('\n');
	}
	if (right != null) {
	    sb.append(right.printNode(depth + 1));
	}
	return sb.toString();
    }
}
